package com.sudo.boot.admin._sys;

import com.sudo.boot.base.constant.enums.BaseEnum;
import com.sudo.boot.base.pojo.JsonRes;
import com.sudo.boot.base.util.BootClassUtil;
import com.sudo.boot.base.util.BootEnumUtil;
import com.sudo.boot.common.constant.ConstantSys;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author DayDayUp
 * @datetime 2023-10-12 18:08
 **/
@RestController
@RequestMapping("enum")
public class EnumController {

    @GetMapping("list/{enumName}")
    public JsonRes<Map<String,String>> list(@PathVariable("enumName") String enumName) {
        Class<BaseEnum<?>> enumClass = BootClassUtil.forName(ConstantSys.enumPath + enumName);
        Map<String, String> stringMap = BootEnumUtil.enumToMap(enumClass);
        return JsonRes.ok(stringMap);
    }
}
